package com.grm.service;

import com.grm.util.TailLogUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.websocket.*;
import javax.websocket.server.ServerEndpoint;

/**
 * desc:
 *
 * @author gaorimao
 * @since 2023-10-23-9:20
 */
@Slf4j
@ServerEndpoint("/websocket/atp/logs")
@Component
public class WebSocketATPRemoteLogs {
    @OnOpen
    public void onOpen(Session session) {
        TailLogUtil.pushLog(session);
    }
    /**
     * 连接关闭
     */
    @OnClose
    public void onClose(Session session) {
    }
    /**
     * 发生错误
     *
     * @param throwable e
     */
    @OnError
    public void onError(Throwable throwable) {
        throwable.printStackTrace();
    }
}
